﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

// allows user sign in
using Microsoft.Xna.Framework.GamerServices;


namespace project_phoenix.source
{
    class MainMenuScreen : MenuScreen
    {
        /// <summary>
        /// Constructor fills in the menu contents.
        /// </summary>
        /// 
        MenuEntry singlePlayerMenuEntry;
        MenuEntry singlePlayerMenuEntry2;
        MenuEntry singlePlayerMenuEntry3;
        MenuEntry exitMenuEntry;


        public MainMenuScreen()
            : base("Main Menu")
        {
            // Create our menu entries.
            singlePlayerMenuEntry = new MenuEntry("Single Player");
            singlePlayerMenuEntry.Description = "Start a New Game";
            singlePlayerMenuEntry.Position = new Vector2(640, 100);

            // Create our menu entries.
            singlePlayerMenuEntry2 = new MenuEntry("Single Player2");
            singlePlayerMenuEntry2.Description = "Start a New Game2";
            singlePlayerMenuEntry2.Position = new Vector2(640, 200);

            // Create our menu entries.
            singlePlayerMenuEntry3 = new MenuEntry("Single Player3");
            singlePlayerMenuEntry3.Description = "Start a New Game3";
            singlePlayerMenuEntry3.Position = new Vector2(640, 300);

            // Create our menu entries.
            exitMenuEntry = new MenuEntry("Exit");
            exitMenuEntry.Description = "Exit the game";
            exitMenuEntry.Position = new Vector2(640, 400);


            // Hook up menu event handlers.
            singlePlayerMenuEntry.Selected += SinglePlayerMenuEntrySelected;
            singlePlayerMenuEntry2.Selected += SinglePlayerMenuEntrySelected;
            singlePlayerMenuEntry3.Selected += SinglePlayerMenuEntrySelected;
            exitMenuEntry.Selected += OnCancel;


            // Add entries to the menu.
            MenuEntries.Add(singlePlayerMenuEntry);
            MenuEntries.Add(singlePlayerMenuEntry2);
            MenuEntries.Add(singlePlayerMenuEntry3);
            MenuEntries.Add(exitMenuEntry);

        }

        /// <summary>
        /// Event handler for when the Single Player menu entry is selected.
        /// </summary>
        void SinglePlayerMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            // brings up a sign in box w/ 4 panes
            //Guide.ShowSignIn(4, false);

            //((MenuEntry)sender).Text = "Selected";
            //singlePlayerMenuEntry4.Text = "TEST";
            //LoadingScreen.Load(ScreenManager, true, e.PlayerIndex,
                             //  new GameplayScreen(null));

            // Go to our character selection screen
            CharacterSelectScreen charSelect = new CharacterSelectScreen();
            ScreenManager.AddScreen(charSelect, null);


        }

        
        /// <summary>
        /// When the user cancels the main menu, ask if they want to exit the sample.
        /// </summary>
        protected override void OnCancel(PlayerIndex playerIndex)
        {
            MessageBoxScreen confirmExitMessageBox =
                                    new MessageBoxScreen("Are you sure you want to quit?");

            confirmExitMessageBox.Accepted += ConfirmExitMessageBoxAccepted;

            ScreenManager.AddScreen(confirmExitMessageBox, playerIndex);

        }

        /// <summary>
        /// Event handler for when the user selects ok on the "are you sure
        /// you want to exit" message box.
        /// </summary>
        void ConfirmExitMessageBoxAccepted(object sender, PlayerIndexEventArgs e)
        {
            ScreenManager.Game.Exit();
        }


        public override void LoadContent()
        {
            // Get the content manager from the screen manager
            ContentManager content = ScreenManager.Game.Content;

            singlePlayerMenuEntry.Font = content.Load<SpriteFont>("fonts\\menuFont");
            singlePlayerMenuEntry2.Font = content.Load<SpriteFont>("fonts\\menuFont");
            singlePlayerMenuEntry3.Font = content.Load<SpriteFont>("fonts\\menuFont");
            exitMenuEntry.Font = content.Load<SpriteFont>("fonts\\menuFont");

        }


    }
}
